package com.zbs.framework.swagger.hander;

import com.zbs.framework.swagger.config.SwaggerBusinessRuntimeException;
import com.zbs.framework.swagger.utils.ResultData;
import com.zbs.framework.swagger.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class SwaggerGlobalExceptionHandler {

    @ExceptionHandler(SwaggerBusinessRuntimeException.class)
    @ResponseBody //为了返回数据
    public ResultData error(SwaggerBusinessRuntimeException e) {
        return ResultUtil.error().message(e.getMessage());
    }

}
